package cn.pconline.autoclub.entity;

import java.util.Date;
import org.apache.commons.lang.StringUtils;
import org.gelivable.dao.Column;
import org.gelivable.dao.Entity;
import org.gelivable.dao.Id;
import org.gelivable.dao.Transient;

/**
 * 车友会帖子实体类
 */
@Entity(tableName = "ac_topic", split = "Mod:clubId:10")
public class Topic {

    @Id
    @Column(name = "id")
    private long id;    //ID
    @Column(name = "club_id")
    private long clubId;    //车友会ID
    @Column(name = "forum_id")
    private long forumId;   //论坛版块ID
    @Column(name = "forum_name")
    private String forumName;   //论坛版块名称
    @Column(name = "user_id")
    private long userId;    //发帖者ID
    @Column(name = "topic_id")
    private long topicId;   //论坛帖子ID            
    @Column(name = "topic_title")
    private String topicTitle;  //论坛帖子标题
    @Column(name = "message")
    private String message; //论坛帖子内容（限140字符）
    @Column(name = "create_at")
    private Date createAt;  //论坛帖子创建时间
    @Column(name = "petrol")
    private int petrol; //帖子油值
    @Column(name = "last_post_by")
    private long lastPostBy;    //论坛帖子最后回复人
    @Column(name = "pick")
    private int pick;   //论坛帖子精华类型, 0不是精华，1为精华1,2为精华2
    @Column(name = "recommend")
    private int recommend;  //论坛帖子推荐类型，0不是推荐，1是推荐
    @Column(name = "image1")
    private String image1;  //帖子图片1
    @Column(name = "image2")
    private String image2;  //帖子图片2
    @Column(name = "image3")
    private String image3;  //帖子图片3
    @Column(name = "last_post_at")
    private Date lastPostAt; //论坛最后回复时间
    @Column(name = "post_count")
    private int postCount;   //帖子回复数
    @Column(name = "last_post_name")
    private String lastPostName;
    @Column(name = "create_date")
    private Date createDate;
    @Transient(cache = false)
    private User topicAuthor;   //帖子作者
//    @Transient(cache = false)
//    private User lastPostAuthor;    //帖子
    @Transient(cache = false)
    private String appImage1;
    @Transient(cache = false)
    private String appImage2;
    @Transient(cache = false)
    private String appImage3;

    /**
     * 帖子页，回复个数（用于分页）
     */
    public static final int TYPE_TOPIC_REPLYSIZE =19;
    /**
     * 帖子页，每页个数
     */
    public static final int TYPE_TOPIC_PAGESIZE =100;
    
    /**
     * 新帖规定时间
     */
    public static final int TYPE_NEW_TOPIC =12;
    
    public String getAppImage1() {
        return convertImgage(image1);
    }

    public String getAppImage2() {
        return convertImgage(image2);
    }

    public String getAppImage3() {
        return convertImgage(image3);
    }

    public String convertImgage(String image) {
        String img = TopicImage.getImgage(image);
        if (StringUtils.isBlank(img)) {
            return img;
        }
        if (img.indexOf("_1024x1024") > 0) {
            return img.replace("_1024x1024", "_240x160");
        }
        return img;
    }

    public long getId() {
        return id;
    }

    public void setId(long id) {
        this.id = id;
    }

    public long getClubId() {
        return clubId;
    }

    public void setClubId(long clubId) {
        this.clubId = clubId;
    }

    public long getForumId() {
        return forumId;
    }

    public void setForumId(long forumId) {
        this.forumId = forumId;
    }

    public String getForumName() {
        return forumName;
    }

    public void setForumName(String forumName) {
        this.forumName = forumName;
    }

    public long getUserId() {
        return userId;
    }

    public void setUserId(long userId) {
        this.userId = userId;
    }

    public long getTopicId() {
        return topicId;
    }

    public void setTopicId(long topicId) {
        this.topicId = topicId;
    }

    public String getTopicTitle() {
        return topicTitle;
    }

    public void setTopicTitle(String topicTitle) {
        this.topicTitle = topicTitle;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public Date getCreateAt() {
        return createAt;
    }

    public void setCreateAt(Date createAt) {
        this.createAt = createAt;
    }

    public int getPetrol() {
        return petrol;
    }

    public void setPetrol(int petrol) {
        this.petrol = petrol;
    }

    public long getLastPostBy() {
        return lastPostBy;
    }

    public void setLastPostBy(long lastPostBy) {
        this.lastPostBy = lastPostBy;
    }

    public int getPick() {
        return pick;
    }

    public void setPick(int pick) {
        this.pick = pick;
    }

    public int getRecommend() {
        return recommend;
    }

    public void setRecommend(int recommend) {
        this.recommend = recommend;
    }

    public String getImage1() {
        return image1;
    }

    public void setImage1(String image1) {
        this.image1 = image1;
    }

    public String getImage2() {
        return image2;
    }

    public void setImage2(String image2) {
        this.image2 = image2;
    }

    public String getImage3() {
        return image3;
    }

    public void setImage3(String image3) {
        this.image3 = image3;
    }

    public Date getLastPostAt() {
        return lastPostAt;
    }

    public void setLastPostAt(Date lastPostAt) {
        this.lastPostAt = lastPostAt;
    }

    public int getPostCount() {
        return postCount;
    }

    public void setPostCount(int postCount) {
        this.postCount = postCount;
    }

    public User getTopicAuthor() {
        return topicAuthor;
    }

    public void setTopicAuthor(User topicAuthor) {
        this.topicAuthor = topicAuthor;
    }

//    public User getLastPostAuthor() {
//        return lastPostAuthor;
//    }
//
//    public void setLastPostAuthor(User lastPostAuthor) {
//        this.lastPostAuthor = lastPostAuthor;
//    }
    public String getLastPostName() {
        return lastPostName;
    }

    public void setLastPostName(String lastPostName) {
        this.lastPostName = lastPostName;
    }

    public Date getCreateDate() {
        return createDate;
    }

    public void setCreateDate(Date createDate) {
        this.createDate = createDate;
    }
}
